<template>
	<view>
		<cu-custom :isBack="true" bgColor="bg-gradual-fff">
			<block slot="content">测评结果</block>
		</cu-custom>
		<u-loading-page :loading="true" loading-text="loading..." v-if="showLoading"></u-loading-page>
		<view v-show="!showLoading">
			<view class="viewbox"></view>
			<view class="group1">
				<view class="p">
					<view class="text1">{{title}}</view>
				</view>
				<view class="content">
					<template v-if="type === 'live'">
						<view v-for="(item,index) in live" :key="index" class="line">
							<text>{{item}}</text>
						</view>
						<view class="line">
							<text>{{expand.content}}</text>
						</view>
						<view class="line">
							<text>你们是：{{detail.mean}}。</text>
						</view>
						<view class="line">
							<text>{{detail.content}}</text>
						</view>
						<view class="line">
							<text>{{monthCodeContent.content}}</text>
						</view>
					</template>
					<template v-if="type === 'forbid'">
						<view v-for="(item,index) in forbid" :key="index" class="line">
							<text>{{item.replace(/TA/g,`${sex==='男'?'她':'他'}`)}}</text>
						</view>
					</template>
					<template v-if="type === 'lesson'">
						<view v-for="(item,index) in lesson" :key="index" class="line">
							<text>{{item.replace(/TA/g,`${sex==='男'?'她':'他'}`)}}</text>
						</view>
					</template>
					<template v-if="type === 'child'">
						<view class="sub-title">引言</view>
						<view v-for="(item,index) in forewordContent" :key="index" class="line">
							<text>{{item}}</text>
						</view>
						<view class="sub-title">建议</view>
						<view v-for="(item,index) in advice" :key="item" class="line">
							<text>{{item}}</text>
						</view>
					</template>
				</view>
			</view>
			<!-- <view class="group2">
				<navigator url="/pages/test_center/evaluate"><button class="btn">写评价</button></navigator>
			</view> -->
		</view>	
	</view>
</template>
<script>
	import {
		getPartnerCodeContent
	} from '@/utils/partnerCode'
	import {
		getMonthCodeContent
	} from '@/utils/monthCode.js'
	import {
		getChildCodeContent,
		forewordContent
	} from '@/utils/childCode.js'
	export default {
		data() {
			return {
				type: '',
				title: '',
				sex: '',
				partnerCodeContent: {
					mean: ''
				},
				childCodeContent: {},
				monthCodeContent: {
					month: '',
					content: '',
				},
				forewordContent: forewordContent
			}
		},
		computed: {
			live() {
				return this.partnerCodeContent?.content || []
			},
			forbid() {
				return this.partnerCodeContent?.forbid || []
			},
			lesson() {
				return this.partnerCodeContent?.lesson?.content || []
			},
			expand() {
				return this.partnerCodeContent?.expand || {
					content: ''
				}
			},
			detail() {
				return this.partnerCodeContent?.detail || {
					mean: '',
					content: ''
				}
			},
			advice() {
				return this.childCodeContent?.advice || []
			}
		},
		onLoad: function(option) { //option为object类型，会序列化上个页面传递的参数
			const params = JSON.parse(option.data || "{}")
			this.sex = params.sex
			this.type = params.type
			this.title = params.title
			const selfBirthday = params.selfBirthday
			const partnerBirthday = params.partnerBirthday
			if (!selfBirthday || !partnerBirthday) {
				return
			}
			this.partnerCodeContent = getPartnerCodeContent(selfBirthday, partnerBirthday)
			this.childCodeContent = getChildCodeContent(selfBirthday, partnerBirthday)
			this.monthCodeContent = getMonthCodeContent(selfBirthday)
		},
	}
</script>

<style  lang="scss" scoped>
	.group1{
		margin: auto;
		margin-top: 60rpx;
		width: 700rpx;
		height: auto;
		border-radius: 20rpx;
		box-shadow: inset 0 0 20rpx 20rpx rgba(85, 56, 105, 1);
		padding: 40rpx;
	}
	.p{
		overflow: hidden;
	}
	.text1{
		// position: absolute;
		font-family: PingFang SC;
		font-weight: 500;
		font-size: 30rpx;
		color: #FFFFFF;
		line-height: 120rpx;
	}
	.content{
		width:100%;
		height: auto;
		font-family: PingFang SC;
		font-weight: 500;
		font-size: 26rpx;
		color: #FFFFFF;
		line-height: 48rpx;
	}
	.group2{
		width: 750rpx;
		height: 120rpx;
		background: #FFFFFF;
		border-radius: 10rpx 10rpx 0rpx 0rpx;
		border: 1px solid #F2F2F2;
		position: fixed;
		bottom: 0rpx;
	}
	.btn{
		margin-top: 16rpx;
		width: 330rpx;
		height: 88rpx;
		background: #62469B;
		border-radius: 44rpx;
		

		font-family: PingFang SC;
		font-weight: 500;
		font-size: 30rpx;
		color: #FFFFFF;
		line-height: 90rpx;
	}
</style>
